package com.atguigu.lease.web.admin.controller.apartment;


import com.atguigu.lease.common.result.Result;
import com.atguigu.lease.web.admin.service.FileService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


@Tag(name = "文件管理")
@RequestMapping("/admin/file")
@RestController
public class FileUploadController {

    @Autowired
    private FileService fileService;
    @Operation(summary = "上传文件")
    @PostMapping("upload")
    public Result<String> upload(@RequestParam MultipartFile file) {
       String url = fileService.upload(file);
        return Result.ok(url);
    }
    // @Operation(summary = "删除文件")
    // @DeleteMapping("delete")
    // //in = ParameterIn.QUERY 表示swagger文档中 该参数描述时 参数传参的位置是哪里
    // // PATH路径参数  HEADER头
    // public Result<String> delete(@Parameter(in = ParameterIn.QUERY , description = "要删除文件的完整路径",
    //         example = "http://cadasdsad:9000/adsad.jpg")@RequestParam("path")String path){
    //     return Result.ok(fileService.delete(path));
    // }

}
